跳到主要内容Skip to main content

采样 / 采样参数Sampling

Sampling

  • 模型能力Model capabilities
  • 第二段 · 上手Stage 2 · Hands On
  • 引用核验 2026-11-19refs checked 2026-11-19
解决什么问题What problem it solves

模型在多个候选词里怎么挑,决定输出的发散程度。How the model picks among candidate tokens — this determines how far the output diverges.

这是什么What it is

一组控制生成过程的参数统称:温度、Top-p、Top-k 等。

它们只影响「怎么挑词」,不影响模型本身的智商。

A collective term for parameters controlling generation: temperature, Top-p, Top-k and so on.

They affect only how a token is chosen, not the intelligence of the model itself.

Logits are scaled by temperature, truncated by top-k/top-p, then sampled from the remaining probabilities.
logits 先经温度缩放,再用 top-k / top-p 截断长尾,最后按剩余概率抽样;参数决定多样性与稳定性。Logits are scaled by temperature, truncated by top-k/top-p, then sampled from the remaining probabilities.
为什么需要知道Why it matters

知道这组参数后,模型输出的不稳定就有了可解释的原因。而不是「它今天抽风」。Once you know these parameters, unstable output has an explainable cause instead of "it was feeling odd today".

出处Sources
  • Gemini 采样参数(topK/topP)Gemini sampling parameters (topK/topP) ↗
  • Anthropic Messages 采样参数Anthropic Messages API sampling parameters ↗
用这个术语做任务Use this term in a task

别停在定义:去任务手册看按什么顺序做、验收什么;或者按你手头的任务,筛 3 个工具候选。Don’t stop at the definition: use the task handbook for the order and checks, or filter three tool candidates for the job at hand.

任务手册 →Task handbooks → · 按任务筛 3 个候选 →Filter three candidates →